package code.jdbc;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/11/24 11:57
 * @package code.jdbc
 * @description jdbc 连接数据库
 */

public class Connection {

}


class frame5 {
    public static void main(String[] args) {
        JFrame frame=new JFrame("平方");
        frame.setLayout(new FlowLayout());
        frame.setSize(500,500);
        JButton button=new JButton("按钮");
        frame.add(button);
        JTextField text=new JTextField(10);
        frame.add(text);
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int num=Integer.parseInt(text.getText());
                text.setText(String.valueOf(num*num));
                System.out.println(num*num);
            }
        });
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        frame.setVisible(true);
    }
}
